<template>
    <bi-select 
    icon="fa-sliders"
    :loading ="loading"
    :disabled="disabled"
    :placeholder="placeholder"
    v-model ="value"
    :clear="true"
    >
      <bi-select-option v-for="(item) in list" :key="item.variant_id" :value="item.variant_id" :label="item.title" ></bi-select-option>
    </bi-select>
</template>
<script>
import fieldMixin from  '@@/admin/assets/bi-plug/fieldMixin.js';
export default{
    mixins:[fieldMixin],
    data(){
        return {
            list:[],
            item:{},
            loading:false
        }
    },
    props:{
        
    },
    methods:{
        refresh(){
            this.loading = true;
            this.$ajax({
                url:this.$url({app:'shop','controller':'admin.field','action':'variantOption'}),
                data:{
                    type:this.type
                },
                success:(data)=>{
                    this.list = data;
                    this.$user.setLocalStorage('shop-variant',data,60);
                    this.loading = false;
                }
            });
        },
        getData(){
            return this.item;
        }
    },
    mounted(){

        let list = this.$user.getLocalStorage('shop-variant');
        if (list){
            this.list = list;
        }else{
            this.refresh();
        }
    }
}
</script>